using ERP.Domain.Products;
using Product.API.ISerivces.ProcessRoute;
using Repository.communal;

namespace Product.API.Serivces.ProcessRoute
{
    /// <summary>
    /// 工艺路线服务实现类
    /// </summary>
    public class ProcessRouteSerivce : IProcessRouteSerivce
    {
        /// <summary>
        /// 工艺路线仓储
        /// </summary>
        private readonly IBaseRepository<ERP.Domain.Products.ProcessRoute> processRouteRepository;

        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="processRouteRepository">工艺路线仓储</param>
        public ProcessRouteSerivce(IBaseRepository<ERP.Domain.Products.ProcessRoute> processRouteRepository)
        {
            this.processRouteRepository = processRouteRepository;
        }

        /// <summary>
        /// 工艺路线添加
        /// </summary>
        /// <param name="processRoute">工艺路线信息</param>
        /// <returns>返回受影响行数</returns>
        public async Task<int> CreateProcessRoute(ERP.Domain.Products.ProcessRoute processRoute)
        {
            var result = await processRouteRepository.AddAsync(processRoute);
            return result;
        }

        /// <summary>
        /// 工艺路线删除（逻辑）
        /// </summary>
        /// <param name="Id">主键</param>
        /// <returns>返回受影响行数</returns>
        public async Task<int> DeleteProcessRoute(int Id)
        {
            var data = await processRouteRepository.GetModelAsync(Id);
            data.IsDelete = true;
            int result = await processRouteRepository.Update(data);
            return result;
        }

        /// <summary>
        /// 工艺路线修改
        /// </summary>
        /// <param name="processRoute">工艺路线信息</param>
        /// <returns>返回受影响行数</returns>
        public async Task<int> UpdateProcessRoute(ERP.Domain.Products.ProcessRoute processRoute)
        {
            var result = await processRouteRepository.Update(processRoute);
            return result;
        }
    }
}


